import QtQuick 1.0
import com.nokia.meego 1.0
import "HarmattanUIConstants.js" as Constants

Rectangle {
    id: progressLabel

    property alias value: progressBar.value
    property alias text: informativeText.text
    property int defaultHeight: Constants.DEFAULT_BAR_HEIGHT * 1.5

    /**
     * Displays the label.
     */
    function show()
    {
        if (hideTimer.running) {
            hideTimer.stop();
        }

        opacity = 1.0;
        height = defaultHeight;
    }

    /**
     * Hides the label.
     */
    function hide()
    {
        //if (opacity > 0) {
            hideTimer.restart();
        //}
    }

    height: defaultHeight
    color: Constants.DARK_TRANSLUCENT

    Behavior on height { NumberAnimation { duration: 250 } }
    Behavior on opacity { NumberAnimation { duration: 250 } }

    Column {
        anchors {
            fill: parent
            margins: Constants.DEFAULT_MARGIN
        }

        spacing: Constants.DEFAULT_MARGIN

        Text {
            id: informativeText
            width: progressLabel.width
            height: progressLabel.height / 2
            verticalAlignment: Text.AlignVCenter
            color: Constants.DEFAULT_TEXT_COLOR
            font.pixelSize: Constants.DEFAULT_FONT_PIXEL_SIZE
        }

        ProgressBar {
            id: progressBar
            width: parent.width
        }
    }

    Timer {
        id: hideTimer
        repeat: false
        running: false
        interval: 3000

        onTriggered: {
            progressLabel.height = 0;
            progressLabel.opacity = 0;
        }
    }
}

// End of file.
